package com.lanou3g.ptp.taskstudent.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.lanou3g.ptp.entity.TaskRole;
import com.lanou3g.ptp.entity.TaskStudent;
import com.lanou3g.ptp.taskstudent.mapper.TaskStudentMapper;
import com.lanou3g.ptp.taskstudent.service.TaskStudentService;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class TaskStudentServiceImpl implements TaskStudentService {

    @Autowired
    TaskStudentMapper taskStudentMapper;

    @Override
    public List<TaskStudent> findAll(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        return taskStudentMapper.findAll();
    }

    @Override
    public TaskStudent findById(Long id) {
        return taskStudentMapper.findById(id);
    }

    @Override
    public void insert(ArrayList<TaskStudent> taskStudents) {
        taskStudentMapper.inserts(taskStudents);
    }

    @Override
    public void update(Long id, TaskStudent taskStudent) {
        taskStudent.setUpdateTime(new Date());
        taskStudentMapper.update(id, taskStudent);
    }

    @Override
    public void delete(Long id) {
        taskStudentMapper.delete(id);
    }

    @Override
    public void deletes(Long[] ids) {
        taskStudentMapper.deletes(ids);
    }

    @Override
    public void deleteByTaskId(Long taskId) {
        taskStudentMapper.deleteByTaskId(taskId);
    }

    @Override
    public void deletesByTaskIds(Long[] ids) {
        taskStudentMapper.deletesByTaskIds(ids);
    }

    @Override
    public ArrayList<Long> findByTaskId(Long id) {
        ArrayList<Long> byTaskId = taskStudentMapper.findByTaskId(id);
        return byTaskId;
    }

    @Override
    public List<TaskStudent> findAllByStudentId(Long studentId) {
        return taskStudentMapper.findAllByStudentId(studentId);
    }
}
